package com.css.cloudlearn.productornacos.sentinel;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * @author 郭辉
 * @className TODO
 * @description TODO
 * @date 2022/11/21 19:58
 * @company 海康威视
 * @since 1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/error")
public class WebController {

    @RequestMapping("/blockHandler")
    public Object globalBlockHandler(){
      log.debug("blockHandler");
      Map<String,Object> result = new HashMap<>();
      result.put("status", HttpServletResponse.SC_BAD_REQUEST);
      result.put("message","Blocked by Sentinel (flow limiting)");
      return result;
    }
}
